package com.ruoyi.graduate.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.graduate.ai.TongyiQianwenClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * AI控制接口
 */
@RestController
@RequestMapping("/api/AI")
@Api(tags = "AI控制接口")
public class MsAIController extends BaseController {

    @Autowired
    private TongyiQianwenClient tongyiQianwenClient;


    @GetMapping
    @ApiOperation("AI对话")
    public AjaxResult get(String param) {

        try {
            String s = tongyiQianwenClient.callQianwenAPI(param);

            return AjaxResult.success(s);
        } catch (Exception e) {

            return AjaxResult.error(e.getMessage());
        }
    }
}
